package com.xingkeduo.controller.cms.marketing;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xingkeduo.feign.HairstyleFeignService;
import com.xingkeduo.feign.ManageUserFeignService;
import com.xingkeduo.service.cms.marketing.MarketingReceiveService;
import com.xingkeduo.util.Constant;
import com.xingkeduo.util.ResponseUtils;
import com.xingkeduo.util.tool.ResponseMessage;

/**
 * 
 * @ClassName: ManagementCouponController
 * @Description: 市场营销管理-公共处理接口相关
 * @author lixin
 * @date Apr 18, 2019 9:11:07 PM
 *
 */
@RestController
@RequestMapping(Constant.CMS_URL_PREFIX + "/common")
public class CommonCmsController {

	@Autowired
	HairstyleFeignService hairstyleFeignService;
	@Autowired
	ManageUserFeignService manageUserFeignService;
	@Autowired
	MarketingReceiveService marketingReceiveService;

	@PostMapping("/getHairstyleServiceList")
	public ResponseMessage getHairstyleServiceList() {
		ResponseUtils<Object> result = hairstyleFeignService.doHairGet("{}");
		if (result.success()) {
			return ResponseMessage.ok(result.getData());
		}
		return ResponseMessage.error(result.getMsg(), 500);
	}

	@PostMapping("/getStoreList")
	public ResponseMessage getStoreList() {
		String result = hairstyleFeignService.doStoreGet("{}");
		JSONObject resultJson = JSON.parseObject(result);
		String status = resultJson.getOrDefault("status", "0") == null ? "0"
				: resultJson.getOrDefault("status", "0").toString();
		return status.equals("1") ? ResponseMessage.ok(resultJson.get("data"))
				: ResponseMessage.error((resultJson.getOrDefault("msg", "") == null ? ""
						: resultJson.getOrDefault("msg", "").toString()), 500);

	}

	@PostMapping("/getManageUserList")
	public ResponseMessage getManageUserList() {
		return manageUserFeignService.doGet("{}");

	}

	@PostMapping("/getConsumptionOrderDetail")
	public ResponseMessage getConsumptionOrderDetail(Integer orderId) {
		return ResponseMessage.ok("获取消费订单详情");

	}
	@RequestMapping("/pushReminder")
	public ResponseMessage pushReminder() {
		return marketingReceiveService.pushExpirationReminder();
	}
	
	@RequestMapping("/expireAbolishCoupon")
	public ResponseMessage expireAbolishCoupon() {
		return marketingReceiveService.expireAbolishCoupon();
	}
	@RequestMapping("/expireAbolishCard")
	public ResponseMessage expireAbolishCard() {
		return marketingReceiveService.expireAbolishCard();
	}
//    @PostMapping("/getUserBalanceList")
//    public ResponseMessage getUserBalanceList(@RequestBody Object queyUserExample) {
//        return ResponseMessage.ok("获取用户余额列表");
//
//    }
}
